#include "../a.h"

/*
第五章 异常处理

*/
class Bad_area{};
int area(int,int);
int main(int argc, char const *argv[])
{
	int a=10;
	int b=20;
	int c=area(a,b);
	cout<<c<<endl;
	int d;
	try{
		d=area(-10,a);

	}catch(Bad_area){
		cout<<"发生异常!"<<endl;
		d=-1;
	}
	cout<<d<<endl;

	

	return 0;
}
int area(int length,int width){
	if (length<=0 || width<=0){
		throw Bad_area();
	}
	return length*width;
}